package com.smh.a07Test1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {

        ServerSocket ss = new ServerSocket(10001);

        Socket accept = ss.accept();
        InputStream is = accept.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));

        StringBuilder sb = new StringBuilder();
        int b;
        //只要客户端不关,这里会一直做循环
        while ((b = br.read()) != -1) {
            sb.append((char) b);
            System.out.print((char) b);
        }
        System.out.println(sb);

        br.close();
        ss.close();


    }
}
